Going the Distance with Babylon.js by Josh Elster

Going the Distance with Babylon.js by Josh Elster

Author:Josh Elster
Language: eng
Format: epub, pdf
Publisher: Packt
Published: 2022-12-15T00:00:00+00:00


Figure 8.6 – The Alien.gltf model. The Scene Inspector window shows the __root__ transform node. From https://playground.babylonjs.com/#8IMNBM#1

The Alien geometry is what we’re interested in working with, but because it is parented to the __root__ node, any changes to the position, rotation, or scaling of Alien are evaluated in a coordinate space relative to that root node, resulting in undesired and unpredictable results. The solution to this is simple and answers our earlier question regarding what was up with our loadAssets code – unparent the desired mesh and dispose of the root. Once that’s accomplished, the rest of the code in our truck loading method is all housekeeping setup for the model – with some important considerations to keep in mind:

Order of operations is important, but not in the way you might think. Changes to a TransformNode (which Mesh is a descendent of) over a given frame are applied in the fixed order of Transform, Rotate, Scale (TRS).

Use setParent(null) rather than the alternative of setting mesh.parent = null. The setParent function preserves positional and rotational values, whereas setting the parent to null does not. This results in any root transformations being removed from the mesh, which is why we need to reset the position and rotation vectors.

Once the transformations have been cleared and the scaling has been set to world-appropriate values, the mesh geometry will need to have new bounding information generated. Otherwise, collisions won’t work properly. The solution to this is the two-step process of calling mesh.bakeCurrentTransformIntoVertices() before calling mesh.refreshBoundingInfo().



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Popular ebooks
Deep Learning with Python by François Chollet(11958)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7429)
Hands-On Unity 2022 Game Development by Nicolas Alejandro Borromeo(2700)
Autodesk Civil 3D 2024 from Start to Finish by Stephen Walz Tony Sabat(2648)
Mathematics for Game Programming and Computer Graphics by Penny de Byl(2560)
Drawing Shortcuts: Developing Quick Drawing Skills Using Today's Technology by Leggitt Jim(2545)
The 46 Rules of Genius: An Innovator's Guide to Creativity (Voices That Matter) by Marty Neumeier(2325)
Taking Blender to the Next Level by Ruan Lotter(2234)
Rapid Viz: A New Method for the Rapid Visualization of Ideas by Kurt Hanks & Larry Belliston(2222)
Express Your Creativity with Adobe Express by Rosie Sue(2209)
Learn Qt 5: Build modern, responsive cross-platform desktop applications with Qt, C++, and QML by Nicholas Sherriff(2189)
Fusion 360 for Makers by Lydia Sloan Cline(1997)
Hands-On Neural Networks with Keras by Niloy Purkait(1937)
Mastering GUI Programming with Python by Alan D. Moore(1796)
Hands-On Unity 2022 Game Development - Third Edition by Nicolas Alejandro Borromeo(1726)
Game Physics Cookbook by Gabor Szauer(1586)
Creative Character Design by Bryan Tillman(1572)
Going the Distance with Babylon.js by Josh Elster(1509)
Unreal Engine 5 Character Creation, Animation, and Cinematics by Henk Venter & Wilhelm Ogterop(1497)
Unreal Engine 4 Game Development Quick Start Guide by Rachel Cordone(1463)